﻿package kizzo.datastruct 
{

	public class BinaryTreeNode 
	{
		public var key:int;
		
		private var left:BinaryTreeNode;
		private var right:BinaryTreeNode;
		private var parent:BinaryTreeNode;
		
		/*
		 * Creates a binary tree node with key key, and children left and right, which default to null.
		 */
		public function BinaryTreeNode(key:int)
		{
			this.key = key;			
			this.left = null;
			this.right = null;
		}		
		
		public function getLeft():BinaryTreeNode
		{
			return left;
		}
		
		public function getRight():BinaryTreeNode
		{
			return right;
		}		
		
		public function getParent():BinaryTreeNode
		{			
			return this.parent;
		}		
		
		public function setLeft(node:BinaryTreeNode):void
		{
			this.left = node;
		}
		
		public function setRight(node:BinaryTreeNode):void
		{
			this.right = node;
		}	
		
		public function setParent(node:BinaryTreeNode):void
		{
			this.parent = node;
		}			
		
		public function hasLeft():Boolean
		{
			return (this.left != null);
		}
		
		public function hasRight():Boolean
		{
			return (this.right != null);
		}
		
	}
	
}